#pragma once

#include "ActionInputPin.h"

#include "Action.h"

namespace uml {

ActionInputPin::ActionInputPin(const QString& umlType)
    : InputPin(umlType) {}

void ActionInputPin::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    InputPin::fromJson(json, errorList);
    fromAction_ = JsonSerializable::create<Action>(json.value("fromAction"), errorList);

}

void ActionInputPin::toJson(QJsonObject& json) {
    InputPin::toJson(json);
    if (fromAction_) {
        QJsonObject fromAction_json;
        fromAction_->toJson(fromAction_json);
        json.insert("fromAction", fromAction_json);
    }
}

/// <summary>
/// fromAction getter
/// The Action used to provide the values of the ActionInputPin.
/// </summary>
shared_ptr<Action> ActionInputPin::fromAction() const {
    return fromAction_;
}

/// <summary>
/// fromAction setter
/// The Action used to provide the values of the ActionInputPin.
/// </summary>
void ActionInputPin::setFromAction(shared_ptr<Action> value) {
    fromAction_ = value;
}

} // namespace uml
